2020-2021 Sunseeker Telemetry and Lighting System
eusci_a_uart.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // eusci_a_uart.h - Driver for the EUSCI_A_UART Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_EUSCI_A_UART_H__
8 #define __MSP430WARE_EUSCI_A_UART_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_EUSCI_Ax__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
28 // The following values are the sync characters possible.
29 //
30 //*****************************************************************************
31 #define DEFAULT_SYNC 0x00
32 #define EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC 0x55
33 
34 //*****************************************************************************
35 //
37 //
38 //*****************************************************************************
39 typedef struct EUSCI_A_UART_initParam {
45  uint8_t selectClockSource;
47  uint16_t clockPrescalar;
51  uint8_t firstModReg;
55  uint8_t secondModReg;
61  uint8_t parity;
66  uint16_t msborLsbFirst;
71  uint16_t numberofStopBits;
78  uint16_t uartMode;
83  uint8_t overSampling;
84 } EUSCI_A_UART_initParam;
85 
86 
87 //*****************************************************************************
88 //
89 // The following are values that can be passed to the param parameter for
90 // functions: EUSCI_A_UART_init().
91 //
92 //*****************************************************************************
93 #define EUSCI_A_UART_NO_PARITY 0x00
94 #define EUSCI_A_UART_ODD_PARITY 0x01
95 #define EUSCI_A_UART_EVEN_PARITY 0x02
96 
97 //*****************************************************************************
98 //
99 // The following are values that can be passed to the param parameter for
100 // functions: EUSCI_A_UART_init().
101 //
102 //*****************************************************************************
103 #define EUSCI_A_UART_MSB_FIRST UCMSB
104 #define EUSCI_A_UART_LSB_FIRST 0x00
105 
106 //*****************************************************************************
107 //
108 // The following are values that can be passed to the param parameter for
109 // functions: EUSCI_A_UART_init().
110 //
111 //*****************************************************************************
112 #define EUSCI_A_UART_MODE UCMODE_0
113 #define EUSCI_A_UART_IDLE_LINE_MULTI_PROCESSOR_MODE UCMODE_1
114 #define EUSCI_A_UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE UCMODE_2
115 #define EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE UCMODE_3
116 
117 //*****************************************************************************
118 //
119 // The following are values that can be passed to the param parameter for
120 // functions: EUSCI_A_UART_init().
121 //
122 //*****************************************************************************
123 #define EUSCI_A_UART_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
124 #define EUSCI_A_UART_CLOCKSOURCE_ACLK UCSSEL__ACLK
125 
126 //*****************************************************************************
127 //
128 // The following are values that can be passed to the param parameter for
129 // functions: EUSCI_A_UART_init().
130 //
131 //*****************************************************************************
132 #define EUSCI_A_UART_ONE_STOP_BIT 0x00
133 #define EUSCI_A_UART_TWO_STOP_BITS UCSPB
134 
135 //*****************************************************************************
136 //
137 // The following are values that can be passed to the param parameter for
138 // functions: EUSCI_A_UART_init().
139 //
140 //*****************************************************************************
141 #define EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION 0x01
142 #define EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION 0x00
143 
144 //*****************************************************************************
145 //
146 // The following are values that can be passed to the mask parameter for
147 // functions: EUSCI_A_UART_enableInterrupt(), and
148 // EUSCI_A_UART_disableInterrupt().
149 //
150 //*****************************************************************************
151 #define EUSCI_A_UART_RECEIVE_INTERRUPT UCRXIE
152 #define EUSCI_A_UART_TRANSMIT_INTERRUPT UCTXIE
153 #define EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT UCRXEIE
154 #define EUSCI_A_UART_BREAKCHAR_INTERRUPT UCBRKIE
155 #define EUSCI_A_UART_STARTBIT_INTERRUPT UCSTTIE
156 #define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT UCTXCPTIE
157 
158 //*****************************************************************************
159 //
160 // The following are values that can be passed to the mask parameter for
161 // functions: EUSCI_A_UART_getInterruptStatus(), and
162 // EUSCI_A_UART_clearInterrupt() as well as returned by the
163 // EUSCI_A_UART_getInterruptStatus() function.
164 //
165 //*****************************************************************************
166 #define EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG UCRXIFG
167 #define EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG UCTXIFG
168 #define EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG UCSTTIFG
169 #define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG UCTXCPTIFG
170 
171 //*****************************************************************************
172 //
173 // The following are values that can be passed to the mask parameter for
174 // functions: EUSCI_A_UART_queryStatusFlags() as well as returned by the
175 // EUSCI_A_UART_queryStatusFlags() function.
176 //
177 //*****************************************************************************
178 #define EUSCI_A_UART_LISTEN_ENABLE UCLISTEN
179 #define EUSCI_A_UART_FRAMING_ERROR UCFE
180 #define EUSCI_A_UART_OVERRUN_ERROR UCOE
181 #define EUSCI_A_UART_PARITY_ERROR UCPE
182 #define EUSCI_A_UART_BREAK_DETECT UCBRK
183 #define EUSCI_A_UART_RECEIVE_ERROR UCRXERR
184 #define EUSCI_A_UART_ADDRESS_RECEIVED UCADDR
185 #define EUSCI_A_UART_IDLELINE UCIDLE
186 #define EUSCI_A_UART_BUSY UCBUSY
187 
188 //*****************************************************************************
189 //
190 // The following are values that can be passed to the deglitchTime parameter
191 // for functions: EUSCI_A_UART_selectDeglitchTime().
192 //
193 //*****************************************************************************
194 #define EUSCI_A_UART_DEGLITCH_TIME_2ns 0x00
195 #define EUSCI_A_UART_DEGLITCH_TIME_50ns UCGLIT0
196 #define EUSCI_A_UART_DEGLITCH_TIME_100ns UCGLIT1
197 #define EUSCI_A_UART_DEGLITCH_TIME_200ns (UCGLIT0 + UCGLIT1)
198 
199 //*****************************************************************************
200 //
201 // Prototypes for the APIs.
202 //
203 //*****************************************************************************
204 
205 //*****************************************************************************
206 //
228 //
229 //*****************************************************************************
230 extern bool EUSCI_A_UART_init(uint16_t baseAddress,
231  EUSCI_A_UART_initParam *param);
232 
233 //*****************************************************************************
234 //
249 //
250 //*****************************************************************************
251 extern void EUSCI_A_UART_transmitData(uint16_t baseAddress,
252  uint8_t transmitData);
253 
254 //*****************************************************************************
255 //
266 //
267 //*****************************************************************************
268 extern uint8_t EUSCI_A_UART_receiveData(uint16_t baseAddress);
269 
270 //*****************************************************************************
271 //
296 //
297 //*****************************************************************************
298 extern void EUSCI_A_UART_enableInterrupt(uint16_t baseAddress,
299  uint8_t mask);
300 
301 //*****************************************************************************
302 //
326 //
327 //*****************************************************************************
328 extern void EUSCI_A_UART_disableInterrupt(uint16_t baseAddress,
329  uint8_t mask);
330 
331 //*****************************************************************************
332 //
354 //
355 //*****************************************************************************
356 extern uint8_t EUSCI_A_UART_getInterruptStatus(uint16_t baseAddress,
357  uint8_t mask);
358 
359 //*****************************************************************************
360 //
378 //
379 //*****************************************************************************
380 extern void EUSCI_A_UART_clearInterrupt(uint16_t baseAddress,
381  uint16_t mask);
382 
383 //*****************************************************************************
384 //
394 //
395 //*****************************************************************************
396 extern void EUSCI_A_UART_enable(uint16_t baseAddress);
397 
398 //*****************************************************************************
399 //
409 //
410 //*****************************************************************************
411 extern void EUSCI_A_UART_disable(uint16_t baseAddress);
412 
413 //*****************************************************************************
414 //
445 //
446 //*****************************************************************************
447 extern uint8_t EUSCI_A_UART_queryStatusFlags(uint16_t baseAddress,
448  uint8_t mask);
449 
450 //*****************************************************************************
451 //
463 //
464 //*****************************************************************************
465 extern void EUSCI_A_UART_setDormant(uint16_t baseAddress);
466 
467 //*****************************************************************************
468 //
478 //
479 //*****************************************************************************
480 extern void EUSCI_A_UART_resetDormant(uint16_t baseAddress);
481 
482 //*****************************************************************************
483 //
493 //
494 //*****************************************************************************
495 extern void EUSCI_A_UART_transmitAddress(uint16_t baseAddress,
496  uint8_t transmitAddress);
497 
498 //*****************************************************************************
499 //
514 //
515 //*****************************************************************************
516 extern void EUSCI_A_UART_transmitBreak(uint16_t baseAddress);
517 
518 //*****************************************************************************
519 //
528 //
529 //*****************************************************************************
530 extern uint32_t EUSCI_A_UART_getReceiveBufferAddress(uint16_t baseAddress);
531 
532 //*****************************************************************************
533 //
542 //
543 //*****************************************************************************
544 extern uint32_t EUSCI_A_UART_getTransmitBufferAddress(uint16_t baseAddress);
545 
546 //*****************************************************************************
547 //
559 //
560 //*****************************************************************************
561 extern void EUSCI_A_UART_selectDeglitchTime(uint16_t baseAddress,
562  uint16_t deglitchTime);
563 
564 //*****************************************************************************
565 //
566 // Mark the end of the C bindings section for C++ compilers.
567 //
568 //*****************************************************************************
569 #ifdef __cplusplus
570 }
571 #endif
572 
573 #endif
574 #endif // __MSP430WARE_EUSCI_A_UART_H__
uint8_t transmitData
MPU_initThreeSegmentsParam param